<?php
namespace app\api\service;
/**
 * UserInfo Service
 * User: zng
 * Date: 2019/10/24
 * Time: 16:25
 */
use app\api\model\user\UserInfo as UserInfoModel;

class UserInfo {

    /**
     * 更新或添加用户信息
     * @author zx
     * @date 2019-10-25
     * @return array
     */
    public function saveUserInfo(array $data, int $uid)
    {
        $userInfo = UserInfoModel::uid($uid)->findOrEmpty();
        $isUpdate = true;
        if ( $userInfo->isEmpty() ) {
            $isUpdate = false;
            $data['uid'] = $uid;
        }
        return $userInfo->isUpdate($isUpdate)->save($data);
    }

}